The present invention is directed to controlling access to an object shared amongst a plurality of processes in a distributed system, so that the shared object is accessed by one and only one process at a time.
1. Field of the Invention
The present invention is directed to controlling access to an object shared amongst a plurality of processes in a distributed system, so that the shared object is accessed by one and only one process at a time.
2. Discussion of the Related Art
In a distributed connection-oriented switched network, a plurality of distributed processes are employed to provide command, control and connectivity in the network; see, for example, the Virtual Network Services (VNS) described in co-pending and commonly owned U.S. Ser. No. 08/622,866 filed Mar. 29, 1996, by S. Thebaut et al., now U.S. Pat. No. 5,889,953, hereby incorporated by reference in its entirety. Due to constant inter-process interaction, some method is required to coordinate the functions of these processes and the objects they share. One such method is to coordinate the instantiation of the shared objects; see, for example, the Replicated Resource Management (RRM) tools described in co-pending and commonly owned U.S. Ser. No. 08/585,054 filed Jan. 11, 1996, by J. Jeffords et al., U.S. Pat. No. 6,233,623, hereby incorporated by reference in its entirety. In applications utilizing RRM, objects can be created or destroyed at any time and are replicated across the processes at the time of creation.
Methods are also, however, needed to manage the lifecycles of these replicated objects, e.g., coordinating access to the object and/or determining when an object is no longer needed and may be destroyed. In co-pending and commonly-owned U.S. patent application Ser. No. 08/873,549, filed concurrently herewith by Jeffords et al., entitled xe2x80x9cMethod and Apparatus For Coordinated Management Of a Shared Object hereby incorporated by reference in its entirety, a method and apparatus are described for management and coordination of a shared object amongst a plurality of processes in a distributed system. In this system, an object has one and only one owner process which is responsible for the creation and, therefore, the destruction of the object. When the owner process determines that none of the processes at a given time are interested in the shared object, the owner process will set the shared object as a candidate for being destroyed. Prior to destruction, however, the owner process will still confirm with each other process that it is acceptable to destroy the object. When it is thus confirmed that no processes are interested in an object, then the object will be destroyed.
Another method for management and coordination of a shared object in a distributed system is described in co-pending and commonly-owned U.S. patent application, Ser. No. 08/681,040, filed Jul. 22, 1996 by Jeffords et al. entitled xe2x80x9cMethod For Synchronizing Processes In a Distributed Systemxe2x80x9d, now U.S. Pat. No. 6,041,383, herein incorporated by reference in its entirety. In this system, a lock token is associated with a given shared object. This lock token is transmitted around the distributed system and captured by a process when it desires control of the associated shared object. Only when a process has possession of the token can it access the object. When a process is finished with the token, it transmits the token to a next process requiring access. Conflicts are resolved when more than one process seeks to capture the token at the same time and token loss is prevented if a process fails or is removed while possessing the token.
Thus, in a distributed system where ownership of an object is shared amongst a plurality of processes, a solution is necessary for coordinating the processes in the distributed system.
According to the present invention, a protocol is provided to coordinate synchronization between processes which share an object in a distributed system. A lock owner process controls a lock associated with a shared object. When a process desires access to the object, it requests control of the lock from the lock owner process. Only the lock owner process can grant control of the lock, and thus control of the shared object, to a requesting process. If the lock owner process determines that the lock is already controlled by another process, the requesting process will have to wait until control of the lock has been returned to the lock owner process. Thus, all transactions with regard to the shared object and its lock are performed through the lock owner process. The lock owner process is the central point of synchronization with regard to the particular shared object.
In one embodiment, a computer-implemented method of controlling access to an object shared amongst a plurality of processes in a distributed system includes steps of assigning one process as an owner of a lock associated with the shared object; when a process requires access to the shared object, the process requesting the lock from the lock owner process; when the lock owner process receives the lock request, the lock owner process determining whether or not any process has control of the lock; and when the lock owner process determines that no process has control of the lock, the lock owner process granting control of the lock to the requesting process.
Further, the lock owner process determines whether or not it is currently accessing the shared object associated with the lock.
In addition, when a first requesting process has been granted control of the lock, the first requesting process sending a message to the lock owner process when the first requesting process no longer requires access to the shared object.
When a second requesting process sends a second lock request message to the lock owner process and the first requesting process has not sent a lock release message to the lock owner process, the lock owner process placing the second requesting process in a queue; and when the first requesting process sends the lock release message to the lock owner process, the lock owner process accessing the queue and granting control of the lock to the next requesting process in the queue.
These and other features and benefits of the present invention will be set forth in the following detailed description and drawings which are given by way of example only and are in no way restrictive.